<?php

class Site_Controller_Action extends Zend_Controller_Action
{
    public $_urlbase;
    public $_modulo = 'ead';
    public $titulo = 'Professor Neneco';
    public $_email_contato = 'contato@neneco.com.br'; // alterar tbm no library envio email
    public $_email_admin = 'alenkar.k@gmail.com';         // alterar tbm no library envio email
    
    public $fb_appId = '1475764955975660'; 
    public $fb_appSecret = '25304b0cd7a923ae89a2b7469d9993d3';//'d4f5387e75619c4ad2de421119720c20'; 
    public $fb_redirectUri = 'http://neneco.com.br/site/'; 
    
    public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
    {
        parent::__construct($request, $response);
        $this->_urlbase = $this->getFrontController()->getBaseUrl();
        $this->_controller  = $this->getRequest()->getControllerName();
        $this->_modulo  = $this->_modulo;
        
        $this->view->urlbase = $this->_urlbase;
        $this->view->controller  = $this->_controller;
        $this->view->modulo  = $this->_modulo;
        
        $this->view->fb_appId =  $this->fb_appId; 
        $this->view->fb_appSecret = $this->fb_appSecret; 
        $this->view->fb_redirectUri = $this->fb_redirectUri; 
        
        $this->view->titulo = $this->titulo;
        //$sessao = new Zend_Session_Namespace('Modulos');
        //if(isset($sessao->modulos[$this->_controller])) $this->view->titulo = $sessao->modulos[$this->_controller];
        //else $this->view->titulo = '';
	
        $sessao = new Zend_Session_Namespace('Parametros');
        if(!isset($sessao->parametros['PAR_ID'])){
            $obj = new Ead_Model_DbTable_Parametros();
            $sessao->parametros = $obj->fetchRow()->toArray();
        }
        
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/js/jquery-1.9.1.min.js');
        
        //$this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/development-bundle/ui/minified/jquery.ui.tooltip.min.js');
        
        //$this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/development-bundle/themes/custom-theme/minified/jquery.ui.tooltip.min.css');
            
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/css/custom-theme/jquery-ui-1.10.2.custom.min.css'); 
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.min.js');
        
        $this->view->headLink()->prependStylesheet($this->_urlbase.'/public/media/css/style.min.css'); 
        
        $this->view->headScript()->appendFile($this->_urlbase.'/public/media/js/script.min.js');
        
    }
    
    
    public function paginacao($result) {

        $pagina = intval($this->_getParam('pagina', 1));
         
        $paginator = Zend_Paginator::factory($result);
        // Seta a quantidade de registros por página
        $paginator->setItemCountPerPage(10);
        // numero de paginas que serão exibidas
        $paginator->setPageRange(7);
        // Seta a página atual
        $paginator->setCurrentPageNumber($pagina);
        // Passa o paginator para a view
        $this->view->paginator = $paginator;
    }
    
    public function verificaLogin($action = NULL,$id = NULL){
        if (!Zend_Auth::getInstance()->hasIdentity() && empty(Zend_Auth::getInstance()->getStorage()->read()->USU_LOGIN)){
            $sessao = new Zend_Session_Namespace('retorno');
            $sessao->controler = $this->getRequest()->getControllerName();
            if($action == NULL) $sessao->action = $this->getRequest()->getActionName();
            else $sessao->action = $action;
            if($id == NULL) $sessao->id = '';
            else $sessao->id = $id;
            return $this->_helper->redirector('', 'login', array());
            
        }
    }
    
}

?>

